<?php
/**
 * cpanel.share.php
 * 
 */
if(!defined('IN_SITE') || !defined('IN_ADMIN')) {
	exit('Access Denied');
}

function clearlogstring($str) {
	if(!empty($str)) {
		if(!is_array($str)) {
			$str = s_htmlspecialchars(trim($str));
			$str = str_replace(array("\t", "\r\n", "\n", "   ", "  "), ' ', $str);
		} else {
			foreach ($str as $key => $val) {
				$str[$key] = clearlogstring($val);
			}
		}
	}
	return $str;
}

function implodearray($array, $skip = array()) {
	$return = '';
	if(is_array($array) && !empty($array)) {
		foreach ($array as $key => $value) {
			if(empty($skip) || !in_array($key, $skip)) {
				if(is_array($value)) {
					$return .= "$key={".implodearray($value, $skip)."}; ";
				} else {
					$return .= "$key=$value; ";
				}
			}
		}
	}
	return $return;
}


function tongji($type = 0, $num = 1)
{
	global $administrator, $db, $tablepre;
	if($type > 11 || $type < 1) return false;
	$dateline = date("Y-m-d", time());
	$jilu = $db->result_first("SELECT count(*) FROM {$tablepre}tongji WHERE id='$administrator[id]' AND dateline='$dateline' AND type='$type'");
	if($jilu)
	{
		$db->query("UPDATE {$tablepre}tongji SET num=num+'$num' WHERE id='$administrator[id]' AND dateline='$dateline' AND type='$type'");
	}
	else
	{
		$db->query("INSERT INTO {$tablepre}tongji(dateline, id, name, type, num) VALUES('$dateline', '$administrator[id]', '$administrator[name]', '$type', '$num')");
	}
}
?>